<?php

namespace app\admin\controller;

use app\admin\service\OrderService;

class OrderController extends CommonController
{
    // 获取订单数据的分页列表
    public function getOrderList(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OrderService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getList();
        return $this->return_result($this->returnData);
    }

    // 更新订单
    public function toUpdateOrder(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OrderService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdate();
        return $this->return_result($this->returnData);
    }

    // 订单的详细内容
    public function getOrderDetail(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OrderService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getDetail();
        return $this->return_result($this->returnData);
    }

    // 订单退款
    public function toHandleRefund(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OrderService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toHandleRefund();
        return $this->return_result($this->returnData);
    }

    // 更新派单状态
    public function toUpdateAllot(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OrderService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdateAllot();
        return $this->return_result($this->returnData);
    }

    // 更新派单
    public function toUpdateAllotOrder(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OrderService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdateAllotData();
        return $this->return_result($this->returnData);
    }

    // 更新状态
    public function toUpdateStatusOrder(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OrderService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdateStatus();
        return $this->return_result($this->returnData);
    }

    // 导出数据
    public function toExportData(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OrderService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->exportData();
        return $this->return_result($this->returnData);
    }

    // 订单设置
    public function toSettingOrder($_type){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OrderService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->orderSetting($_type);
        return $this->return_result($this->returnData);
    }

    // 订单提醒
    public function toRemindOrder($_type){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OrderService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->remindSetting($_type);
        return $this->return_result($this->returnData);
    }

    // 删除订单
    public function toDelOrder(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(OrderService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toDel();
        return $this->return_result($this->returnData);
    }

}